package com.pisces.tool.util;

import java.text.DecimalFormat;

public class FormatUtil {

	/**
	 * ex:formatDecimal("123456.789", "#,###.00")
	 * @param data
	 * @param format
	 * @return
	 */
	public static String formatDecimal(String data, String format){
		String r = "";
		DecimalFormat decimalFormat = new DecimalFormat(format);
		
		try {
			Double d = Double.valueOf(data);
			r = decimalFormat.format(d);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return r;
	}
	
	public static void main(String[] args){
		System.out.println("-----" + FormatUtil.formatDecimal("452131.557215", "#,###.00"));
	}


}
